﻿Imports Microsoft.VisualBasic
Imports System.Data

<System.ComponentModel.DataObjectAttribute(True)> _
Public Class BLL_AddWorkHeaderControl

    Public Sub New()
        ' 
        ' TODO: 在此加入建構函式的程式碼 
        ' 
    End Sub

    'SELECT 
    <System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.[Select])> _
    Public Function BLL_Select(ByVal WorkHeaderID As Integer) As DataTable

        Dim sql As New MyStringBuilder
        Dim dat As New clsData

        sql.AppendFormat("select w.*,datepart(Hour,w.WorkStartDate) as TimeStart,datepart(Hour,w.WorkEndDate) as TimeEnd ")
        sql.AppendFormat(",ov.OrganizationName,vv.VOrganizationName,v.VolunteerName,v.OfficePhone ")
        sql.AppendFormat(",w.PreExecutionPhotoName, w.PostExecutionPhotoName ")
        sql.AppendFormat("from WorkHeader w Left outer join OrganizationView ov ")
        sql.AppendFormat("on w.VUOrganizationID=ov.UOrganizationID ")
        sql.AppendFormat("Left outer join VOrganizationViewV2 vv ")
        sql.AppendFormat("on w.VUOrganizationID = '-1,'+cast(vv.VOrganizationID as nvarchar(50) ) ")
        sql.AppendFormat("Left Outer join Volunteer v ")
        sql.AppendFormat("on w.LeaderID = v.VolunteerID ")
        sql.AppendFormat("where w.WorkHeaderID='{0}' ", WorkHeaderID)

        Return dat.GetData(sql)

    End Function

End Class
